#include "com_android_camara_NativeLib.h"


JNIEXPORT jintArray JNICALL Java_com_android_camara_NativeLib_convertToGray
  (JNIEnv * env, jobject obj, jintArray pixels){

	jint i,color=0;
	jint r,g,b=0;
	jint f=0;


	jintArray pixelsreturned;
	jint *retBody;


	jsize len=(*env)->GetArrayLength(env,pixels);
	jint *colorPixels=(*env)->GetIntArrayElements(env,pixels,0);//a recorrer


	pixelsreturned = (*env)->NewIntArray(env, len);
   	retBody = (*env)->GetIntArrayElements(env, pixelsreturned, 0);


	for(i=0;i<len;i++){
			color=colorPixels[i];

			r = (color >> 16) & 0xFF;
			g = (color >> 8) & 0xFF;
			b = (color) & 0xFF;

			f = (int) ((.2125 * r) + (.7154 * g) + (.072 * b));

			retBody[i] = (f << 16) | (f << 8) | (f);
	
	}


	(*env)->ReleaseIntArrayElements(env, pixels, colorPixels, 0);
   	(*env)->ReleaseIntArrayElements(env, pixelsreturned, retBody, 0);

   return pixelsreturned; 
}


JNIEXPORT jintArray JNICALL Java_com_android_camara_NativeLib_convertToNegative
  (JNIEnv * env, jobject obj, jintArray grayPixels){




}

